package com.haixiaoke.saas.repository.service.impl;

import com.haixiaoke.saas.repository.mapper.ApartmentChargeItemMapper;
import com.haixiaoke.saas.repository.pojo.ApartmentChargeItem;
import com.haixiaoke.saas.repository.service.IApartmentChargeItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 公寓收费项目Service业务层处理
 *
 * @author qixi
 * @date 2023-06-13
 */
@Service
public class ApartmentChargeItemServiceImpl implements IApartmentChargeItemService {
    @Autowired
    private ApartmentChargeItemMapper apartmentChargeItemMapper;

    /**
     * 查询公寓收费项目
     *
     * @param itemId 公寓收费项目主键
     * @return 公寓收费项目
     */
    @Override
    public ApartmentChargeItem selectApartmentChargeItemByItemId(Long itemId) {
        return apartmentChargeItemMapper.selectApartmentChargeItemByItemId(itemId);
    }

    /**
     * 查询公寓收费项目列表
     *
     * @param apartmentChargeItem 公寓收费项目
     * @return 公寓收费项目
     */
    @Override
    public List<ApartmentChargeItem> selectApartmentChargeItemList(ApartmentChargeItem apartmentChargeItem) {
        return apartmentChargeItemMapper.selectApartmentChargeItemList(apartmentChargeItem);
    }

    /**
     * 新增公寓收费项目
     *
     * @param apartmentChargeItem 公寓收费项目
     * @return 结果
     */
    @Override
    public int insertApartmentChargeItem(ApartmentChargeItem apartmentChargeItem) {
        apartmentChargeItem.setCreateTime(new Date());
        return apartmentChargeItemMapper.insertApartmentChargeItem(apartmentChargeItem);
    }

    /**
     * 修改公寓收费项目
     *
     * @param apartmentChargeItem 公寓收费项目
     * @return 结果
     */
    @Override
    public int updateApartmentChargeItem(ApartmentChargeItem apartmentChargeItem) {
        apartmentChargeItem.setUpdateTime(new Date());
        return apartmentChargeItemMapper.updateApartmentChargeItem(apartmentChargeItem);
    }

    /**
     * 批量删除公寓收费项目
     *
     * @param itemIds 需要删除的公寓收费项目主键
     * @return 结果
     */
    @Override
    public int deleteApartmentChargeItemByItemIds(Long[] itemIds) {
        return apartmentChargeItemMapper.deleteApartmentChargeItemByItemIds(itemIds);
    }

    /**
     * 删除公寓收费项目信息
     *
     * @param itemId 公寓收费项目主键
     * @return 结果
     */
    @Override
    public int deleteApartmentChargeItemByItemId(Long itemId) {
        return apartmentChargeItemMapper.deleteApartmentChargeItemByItemId(itemId);
    }

    @Override
    public List<ApartmentChargeItem> selectApartmentChargeItemByOrgId(Long orgId) {
        return apartmentChargeItemMapper.selectApartmentChargeItemByOrgId(orgId);

    }

    @Override
    public boolean checkItemNameUnique(String itemName, Long orgId) {
        return apartmentChargeItemMapper.checkItemNameUnique(itemName,orgId) == 0;
    }
}
